package com.eonmind.pay.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @ClassName AsyncConfig
 * @Description TODO
 * Author 32004
 * Date 2025/5/31 19:42
 * Version 1.0
 **/
@Configuration
public class AsyncConfig {
    @Bean(name = "asyncExecutor")
    public ThreadPoolTaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5); // 核心线程数
        executor.setMaxPoolSize(10); // 最大线程数
        executor.setQueueCapacity(100); // 任务队列容量
        executor.setThreadNamePrefix("AsyncThread-"); // 线程名称前缀
        executor.initialize();
        return executor;
    }
}